home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / src / ov-typeinfo.h < prev    next >
C/C++ Source or Header  |  1996-11-07  |  3KB  |  149 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_value_typeinfo_h)
  24. #define octave_value_typeinfo_h 1
  25.  
  26. #if defined (__GNUG__)
  27. #pragma interface
  28. #endif
  29.  
  30. #include <string>
  31.  
  32. #include "Array.h"
  33. #include "Array2.h"
  34. #include "Array3.h"
  35.  
  36. #include "ov.h"
  37.  
  38. class string_vector;
  39.  
  40. class
  41. octave_value_typeinfo
  42. {
  43. public:
  44.  
  45.   static int register_type (const string&);
  46.  
  47.   static bool register_binary_op (octave_value::binary_op, int, int,
  48.                   binary_op_fcn);
  49.  
  50.   static bool register_assign_op (int, int, assign_op_fcn);
  51.  
  52.   static bool register_pref_assign_conv (int, int, int);
  53.  
  54.   static bool register_widening_op (int, int, type_conv_fcn);
  55.  
  56.   static binary_op_fcn
  57.   lookup_binary_op (octave_value::binary_op op, int t1, int t2)
  58.   {
  59.     return instance->do_lookup_binary_op (op, t1, t2);
  60.   }
  61.  
  62.   static assign_op_fcn
  63.   lookup_assign_op (int t_lhs, int t_rhs)
  64.   {
  65.     return instance->do_lookup_assign_op (t_lhs, t_rhs);
  66.   }
  67.  
  68.   static int
  69.   lookup_pref_assign_conv (int t_lhs, int t_rhs)
  70.   {
  71.     return instance->do_lookup_pref_assign_conv (t_lhs, t_rhs);
  72.   }
  73.  
  74.   static type_conv_fcn
  75.   lookup_widening_op (int t, int t_result)
  76.   {
  77.     return instance->do_lookup_widening_op (t, t_result);
  78.   }
  79.  
  80.   static string_vector installed_type_names (void)
  81.   {
  82.     return instance->do_installed_type_names ();
  83.   }
  84.  
  85. protected:
  86.  
  87.   octave_value_typeinfo (void)
  88.     : num_types (0), types (init_tab_sz, string ()),
  89.       binary_ops (octave_value::num_binary_ops, init_tab_sz,
  90.           init_tab_sz, (binary_op_fcn) 0),
  91.       assign_ops (init_tab_sz, init_tab_sz, (assign_op_fcn) 0),
  92.       pref_assign_conv (init_tab_sz, init_tab_sz, -1),
  93.       widening_ops (init_tab_sz, init_tab_sz, (type_conv_fcn) 0)  { }
  94.  
  95. private:
  96.  
  97.   static const int init_tab_sz;
  98.  
  99.   static octave_value_typeinfo *instance;
  100.  
  101.   int num_types;
  102.  
  103.   Array<string> types;
  104.  
  105.   Array3<binary_op_fcn> binary_ops;
  106.  
  107.   Array2<assign_op_fcn> assign_ops;
  108.  
  109.   Array2<int> pref_assign_conv;
  110.  
  111.   Array2<type_conv_fcn> widening_ops;
  112.  
  113.   int do_register_type (const string&);
  114.  
  115.   bool do_register_binary_op (octave_value::binary_op, int, int,
  116.                   binary_op_fcn);
  117.  
  118.   bool do_register_assign_op (int, int, assign_op_fcn);
  119.  
  120.   bool do_register_pref_assign_conv (int, int, int);
  121.  
  122.   bool do_register_widening_op (int, int, type_conv_fcn);
  123.  
  124.   binary_op_fcn
  125.   do_lookup_binary_op (octave_value::binary_op, int, int);
  126.  
  127.   assign_op_fcn do_lookup_assign_op (int, int);
  128.  
  129.   int do_lookup_pref_assign_conv (int, int);
  130.  
  131.   type_conv_fcn do_lookup_widening_op (int, int);
  132.  
  133.   string_vector do_installed_type_names (void);
  134.  
  135.   // No copying!
  136.  
  137.   octave_value_typeinfo (const octave_value_typeinfo&);
  138.  
  139.   octave_value_typeinfo& operator = (const octave_value_typeinfo&);
  140. };
  141.  
  142. #endif
  143.  
  144. /*
  145. ;; Local Variables: ***
  146. ;; mode: C++ ***
  147. ;; End: ***
  148. */
  149.